Page({
  data:{
    movie:{}
  },
  onLoad:function(e){
    this.loadMovieDetail(e);
  },
  btnBuy:function(e){
    var filmName = e.currentTarget.dataset.text+""
    var app = getApp()
    var username=app.globalData.username
    console.log(filmName+'|'+username)
    wx.showToast({
      title: filmName,
      icon: 'none',
      duration: 1500
  })    
  wx.navigateTo({
    url: '../filmTimes/filmTimes?filmName='+filmName+'&username='+username
  })
  },
  loadMovieDetail:function(e){
     var page = this;
     wx.request({
       url: 'http://127.0.0.1:8080/getFilmInfoById_wx',
       data:{
        'film_id': e.id
     },
       header:{
         'Content-Type':'json'
       },
       success:function(res){
          var subject = res.data.data;
          var movie = new Object();
           //电影名称
           movie.name = subject.Film_name;
           //电影海报图片
           movie.pic = "../"+subject.Url;
          //导演
          var director = subject.Director;
           movie.dir = director;
           //主演
          var casts = subject.Actor;
          movie.cast = casts;
          movie.id = subject.Film_id;
           //影片类型
           var genres = subject.Film_type;
          movie.type = genres;
          movie.summary = subject.Film_introduce;
          movie.country = subject.Make_film_area;
          page.setData({movie:movie});
          wx.setNavigationBarTitle({
            title: movie.name
          })
       }
     })
  }
})